package com.site.web.sys.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.util.WebUtils;

import com.site.domain.UserInfo;
import com.site.service.UserService;

@Controller
@RequestMapping("/sys/")
public class MainController {
	private static String SYS_LOGIN = "redirect:/sys/login";
	@Autowired
	private UserService userInfoService;
	
	/**
	 * Purpose: 主页
	 * @author: liangjun
	 * @param request
	 * @param response
	 * @return: ModelAndView
	 */
	@RequestMapping(value="main",method=RequestMethod.GET)
	public ModelAndView main(HttpServletRequest request,HttpServletResponse response) {
		UserInfo userInfo = (UserInfo)WebUtils.getSessionAttribute(request, "userInfo");
		if(null == userInfo){
			return new ModelAndView(SYS_LOGIN);
		}
		return new ModelAndView().addObject("userInfo", userInfo);
	}
	
}
